package com.saclub.app.handler;

import com.offroader.utils.ViewUtils;
import com.saclub.app.R;
import com.saclub.app.bean.page.AccountUserPage;
import com.saclub.app.bean.part.User;
import com.saclub.app.common.AccessTokenKeeper;
import com.saclub.app.fragment.AccountLoginFragment;

public class LoginResponseHandler extends MyBaseHttpResponseHandler<AccountLoginFragment, AccountUserPage> {

	@Override
	public void deal() {

		User user = page.getUser();
		if (user != null && user.isValide()) {
			String mAccessToken = user.getUid();
			String mExpiresTime = String.valueOf(Integer.MAX_VALUE);
			String openId = user.getUid();

			//保存登陆状态信息
			AccessTokenKeeper tokenKeeper = new AccessTokenKeeper(mAccessToken, mExpiresTime, openId, user);
			AccessTokenKeeper.keepAccessToken(caller.getActivity(), tokenKeeper);

			ViewUtils.toast(R.string.tip_login_success);

			caller.getActivity().finish();

		} else {
			ViewUtils.toast(R.string.tip_login_fails);
		}

	}

}
